home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / newmat03.lha / newmat03 / precisio.hxx < prev    next >
Text File  |  1993-08-08  |  3KB  |  120 lines

  1. //$$ precisio.hxx                          floating point constants
  2.  
  3. #ifndef PRECISION_LIB
  4. #define PRECISION_LIB 0
  5.  
  6. #ifndef SystemV                    // if there is float.h
  7.  
  8.  
  9. #ifdef USING_FLOAT
  10.  
  11.  
  12. class FloatingPointPrecision
  13. {
  14. public:
  15.    static int Dig()
  16.       { return FLT_DIG; }        // number of decimal digits or precision
  17.    static real Epsilon()
  18.       { return FLT_EPSILON; }    // smallest number such that 1+Eps!=Eps
  19.    static int Mantissa()
  20.       { return FLT_MANT_DIG; }   // bits in mantisa
  21.    static real Maximum()
  22.       { return FLT_MAX; }        // maximum value
  23.    static int MaximumDecimalExponent()
  24.       { return FLT_MAX_10_EXP; } // maximum decimal exponent
  25.    static int MaximumExponent()
  26.       { return FLT_MAX_EXP; }    // maximum binary exponent
  27.    static real Minimum()
  28.       { return FLT_MIN; }        // minimum positive value
  29.    static int MinimumDecimalExponent()
  30.       { return FLT_MIN_10_EXP; } // minimum decimal exponent
  31.    static int MinimumExponent()
  32.       { return FLT_MIN_EXP; }    // minimum binary exponent
  33.    static int Radix()
  34.       { return FLT_RADIX; }      // exponent radix
  35.    static int Rounds()
  36.       { return FLT_ROUNDS; }     // addition rounding (1 = does round)
  37. };
  38.  
  39. #endif
  40.  
  41.  
  42. #ifdef USING_DOUBLE
  43.  
  44. class FloatingPointPrecision
  45. {
  46. public:
  47.    static int Dig()
  48.       { return DBL_DIG; }        // number of decimal digits or precision
  49.    static real Epsilon()
  50.       { return DBL_EPSILON; }    // smallest number such that 1+Eps!=Eps
  51.    static int Mantissa()
  52.       { return DBL_MANT_DIG; }   // bits in mantisa
  53.    static real Maximum()
  54.       { return DBL_MAX; }        // maximum value
  55.    static int MaximumDecimalExponent()
  56.       { return DBL_MAX_10_EXP; } // maximum decimal exponent
  57.    static int MaximumExponent()
  58.       { return DBL_MAX_EXP; }    // maximum binary exponent
  59.    static real Minimum()
  60.    {
  61. #ifdef __BCPLUSPLUS__
  62.        return 2.225074e-308;     // minimum positive value
  63. #else
  64.        return DBL_MIN;
  65. #endif
  66.    }
  67.    static int MinimumDecimalExponent()
  68.       { return DBL_MIN_10_EXP; } // minimum decimal exponent
  69.    static int MinimumExponent()
  70.       { return DBL_MIN_EXP; }    // minimum binary exponent
  71.    static int Radix()
  72.       { return FLT_RADIX; }      // exponent radix
  73.    static int Rounds()
  74.       { return FLT_ROUNDS; }     // addition rounding (1 = does round)
  75. };
  76.  
  77. #endif
  78.  
  79. #endif
  80.  
  81. #ifdef SystemV                    // if there is no float.h
  82.  
  83. #ifdef USING_FLOAT
  84.  
  85. class FloatingPointPrecision
  86. {
  87. public:
  88.    static real Epsilon()
  89.       { return pow(2.0,1-FSIGNIF); }  // smallest number such that 1+Eps!=Eps
  90.    static real Maximum()
  91.       { return MAXFLOAT; }        // maximum value
  92.    static real Minimum()
  93.       { return MINFLOAT; }        // minimum positive value
  94. };
  95.  
  96. #endif
  97.  
  98.  
  99. #ifdef USING_DOUBLE
  100.  
  101. class FloatingPointPrecision
  102. {
  103. public:
  104.    static real Epsilon()
  105.       { return pow(2.0,1-DSIGNIF); }  // smallest number such that 1+Eps!=Eps
  106.    static real Maximum()
  107.       { return MAXDOUBLE; }          // maximum value
  108.    static real Minimum()
  109.       { return MINDOUBLE; }
  110. };
  111.  
  112. #endif
  113.  
  114. #endif
  115.  
  116.  
  117.  
  118.  
  119. #endif
  120.